Skip to content

Added handling of herbivory waste products to the litter model#583

Merged
jacobcook1995 merged 16 commits intodevelopfrom
510-animal-input-into-litter-model-should-be-improved
Oct 11, 2024
Merged

Added handling of herbivory waste products to the litter model#583
jacobcook1995 merged 16 commits intodevelopfrom
510-animal-input-into-litter-model-should-be-improved

Conversation

@jacobcook1995
Copy link
Copy Markdown
Collaborator

Description

A previous PR (#577) added a flow from the animal model representing waste products from herbivory (e.g. an elephant pulls off a branch but doesn't eat it all and drops the remainder). This PR changes the litter model so that it actually does something with this type of flow (which at present only exists for leaves).

Getting this to work required restructuring of the litter model. Primarily by adding an InputPartition class, which collects all the steps needed to calculate the total input of each plant matter type as well as to calculate the split of each plant matter type between litter pools. This class returns an InputDetails dataclass which gets used by the rest of the litter model. Feedback on this restructure would be very helpful!

Fixes #510

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist

  • Make sure you've run the pre-commit checks: $ pre-commit run -a
  • All tests pass: $ poetry run pytest

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works
  • Relevant documentation reviewed and updated

@jacobcook1995 jacobcook1995 linked an issue Oct 10, 2024 that may be closed by this pull request
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.18%. Comparing base (1bea17b) to head (8ca5363).
Report is 1694 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #583      +/-   ##
===========================================
+ Coverage    95.09%   95.18%   +0.08%     
===========================================
  Files           74       74              
  Lines         4302     4380      +78     
===========================================
+ Hits          4091     4169      +78     
  Misses         211      211              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@davidorme davidorme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the name InputDetails - it's a bit generic. LitterInputs? Asides from that I think the science all looks fine, but as I've noted in comments, the InputPartition/InputDetails implementation feels like a single class thats fallen in half.

@jacobcook1995
Copy link
Copy Markdown
Collaborator Author

@davidorme thanks for the feedback fully agree that the two separate classes were clunky so I have now merged them into one

Copy link
Copy Markdown
Collaborator

@davidorme davidorme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - that seems cleaner. I'd be tempted to rename the module though, since that class is now gone. Probably fine with models/litter/inputs.py?

Copy link
Copy Markdown
Collaborator

@dalonsoa dalonsoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, and pretty clean to put all related stuff in its own class. My only comment is that you change the name of the class to LitterInputs, but let the variables as input_details. I'd change this to litter_inputs to be more explicit about what inputs we are talking about.

from virtual_ecosystem.models.litter.constants import LitterConsts


@dataclass
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the LitterInputs objects are not to be modified after creation, make it frozen with @dataclass(frozen=True) to avoid mistakes.

@jacobcook1995 jacobcook1995 merged commit 028b49d into develop Oct 11, 2024
@jacobcook1995 jacobcook1995 deleted the 510-animal-input-into-litter-model-should-be-improved branch October 11, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Animal input into litter model should be improved

4 participants